The present invention relates to industrial controllers and in particular to a network card that may be attached to industrial controllers to allow the industrial controller to communicate to communication networks of different protocols.
Industrial controllers are special purpose computers used for controlling industrial processes and manufacturing equipment. Under the direction of a stored control program, the industrial controller examines a series of inputs reflecting the status of a controlled process and in response, adjusts a series of outputs controlling the process. The inputs and outputs may be binary, that is, on or off, or analog providing a value within a continuous range of values.
Industrial controllers may communicate with other industrial controllers or remote input and output (I/O) devices by means of well known high speed serial communication networks such as Ethernet, ProfiBus, FieldBus, FireWire, and DeviceNet or by proprietary data networks such as the Data Highway series protocols developed by the assignee of the present application. In order to accommodate this variety of different communication protocols, the industrial controller may be constructed in modular form to allow different network cards to be attached to the industrial controller to communicate with the industrial controller through a common communication interface. Each communication card may be tailored to provide communications with a different network to which it also attaches.
The interface between the network card and the industrial controller must efficiently transmit large amounts of data between the network card (and thus the network) and the industrial controller as part of the communication process. This data exchange may be asynchronous meaning that the reading and writing of data by the network card and the industrial controller may not synchronized with each other.
One simple method of accommodating the transfer of large amounts of asynchronous data between the industrial controller and the network card is by the use of a dual port memory into and from which the industrial controller and the network card may independently write and read. Unfortunately the asynchronicity in reading and writing may allow a portion of the dual port memory to be read at the same time as it is being written thus producing erroneous data. While prohibiting simultaneous reading and writing of the memory may solve this problem, this defeats the purpose of a dual port memory in allowing rapid data transfer.
The present invention provides an extremely simple protocol that allows a dual port memory to be used as an interface between an industrial controller and a network card with simultaneous reading and writing of that dual port memory. Generally, the memory is divided into at least two buffer areas and two registers are used to indicate generally the target of writing (the xe2x80x9cvalid buffer registerxe2x80x9d) and the target of reading (the xe2x80x9cconsumer access registerxe2x80x9d), respectively. The reading device copies the contents of the valid buffer register to the consumer access register until the two are the same, then reads from the buffer indicated by the consumer access register clearing it when it is done. The writing device reads the consumer access register. If it is clear, it writes to the opposite buffer indicated by the valid buffer register. If it is not clear but indicates one of the two buffers, it copies the contents of the consumer access register to the valid buffer register, then it writes to the other buffer than that indicated. In either case, the value of the buffer written to is put into the valid buffer register. Read and write conflicts are thereby precluded.
Specifically, then, the present invention provides an interface for a network card that may be replaceably attached to an industrial controller to provide transmission on a communication network of messages sent from the industrial controller and receipt from the communications network of messages sent to the industrial controller. The interface includes a first and second buffer. A valid buffer register holds a value indicating one of the first and second buffers. A consumer access register holds a value indicating the first or second buffer or when cleared, neither of the first or second buffers. An electronic computer executes a stored program prior to reading one of the first and second buffers to copy a value from the valid buffer register to the consumer access register and then to confirm that the value of the consumer access register equals the value of the valid buffer register. The computer then reads a buffer indicated by the consumer access register and upon completion of the reading clears the consumer access register.
Thus it is one object of the invention to provide an extremely simple protocol that ensures that buffers are not simultaneously written to and read. By copying the valid buffer register to the consumer access register, the reading device provides a signal to any writing devices that a reading is occurring.
It is another object of the invention to prevent errors called by asynchronous reading and writing where the writing device completes a write during the step of copying from the valid buffer register to the consumer access register. The confirming of the value of the consumer access register to be equal to the value of the valid buffer register prevents a writing device from reacting to a stale value in the consumer access register in between the time it takes to read the valid buffer register and write it to the consumer access register.
It is yet another object of the invention to allow a signaling to the writing device of the completion of the reading that is distinct from an indication of one of the two buffers. The clearing of the consumer access register provides this indication
If the value of the consumer access register cannot be confirmed to be equal to the valid buffer register, the electronic computer may repeat the copying process.
Thus it is another object of the invention to allow reading of a buffer to commence as soon as possible after an intervening write of the buffer has been completed such as may change the valid buffer register.
The valid buffer register and the consumer access register in the first and second buffers may be designated portions of a continuous memory space in electronic memory.
Thus it is another object of the invention to allow the present interface to work with a general dual port memory device.
Prior to writing to one of the first and second buffers, the electronic computer may read the consumer access register and when the consumer access register indicates one of the first and second buffers, the electronic computer may write to a buffer that is not indicated by the consumer access register and write the value of the written buffer in the valid buffer register upon completion of the writing. On the other hand, if the consumer access register indicates neither of the first and second buffers, the electronic computer may read the valid buffer register and write to a buffer that is not indicated by the valid buffer register and write a value of the written buffer into the valid buffer register upon completion of the writing.
Thus it is another object of the invention to provide for an efficient method of locking out a writing device when a reading of the buffer is occurring that minimizes the necessary reading of the registers. If a reading process is ongoing, a single read of the consumer access buffer allows the writing device to determine where the proper target buffer is.
It is another object of the invention to provide the writing device the maximum flexibility in selecting the buffer to write if no reading of either buffer is occurring.
The foregoing and other objects and advantages of the invention will appear from the following description. In the description, reference is made to the accompanying drawings which form a part hereof, and in which there is shown by way of illustration a preferred embodiment of the invention. Such embodiment does not necessary represent the full scope of the invention, however, and reference must be made to the claims herein for interpreting the scope of the invention.